clear all
clc
close all

%%PRKS
pdr95_pro_rd1 = GetPdrStdArray('PRKS95_every_link_pdrs_rd1.txt');
pdr95_pro_rd2 = GetPdrStdArray('PRKS95_every_link_pdrs_rd2.txt');
pdr95_pro_rd3 = GetPdrStdArray('PRKS95_every_link_pdrs_rd3.txt');
pdr95_pro_rd4 = GetPdrStdArray('PRKS95_every_link_pdrs_rd4.txt');
pdr95_pro_rd5 = GetPdrStdArray('PRKS95_every_link_pdrs_rd5.txt');
pdr_pro_95 = [pdr95_pro_rd1; pdr95_pro_rd2;pdr95_pro_rd3; pdr95_pro_rd4; pdr95_pro_rd5];
%pdr_pro_95 = abs (pdr_pro_95 - 0.95);

pdr90_pro_rd1 = GetPdrStdArray('PRKS90_every_link_pdrs_rd1.txt');
pdr90_pro_rd2 = GetPdrStdArray('PRKS90_every_link_pdrs_rd2.txt');
pdr90_pro_rd3 = GetPdrStdArray('PRKS90_every_link_pdrs_rd3.txt');
pdr90_pro_rd4 = GetPdrStdArray('PRKS90_every_link_pdrs_rd4.txt');
pdr90_pro_rd5 = GetPdrStdArray('PRKS90_every_link_pdrs_rd5.txt');
pdr_pro_90 = [pdr90_pro_rd1; pdr90_pro_rd2;pdr90_pro_rd3; pdr90_pro_rd4; pdr90_pro_rd5];
%pdr_pro_90 = abs (pdr_pro_90 - 0.90);

pdr80_pro_rd1 = GetPdrStdArray('PRKS80_every_link_pdrs_rd1.txt');
pdr80_pro_rd2 = GetPdrStdArray('PRKS80_every_link_pdrs_rd2.txt');
pdr80_pro_rd3 = GetPdrStdArray('PRKS80_every_link_pdrs_rd3.txt');
pdr80_pro_rd4 = GetPdrStdArray('PRKS80_every_link_pdrs_rd4.txt');
pdr80_pro_rd5 = GetPdrStdArray('PRKS80_every_link_pdrs_rd5.txt');
pdr_pro_80 = [pdr80_pro_rd1; pdr80_pro_rd2;pdr80_pro_rd3; pdr80_pro_rd4; pdr80_pro_rd5];
%pdr_pro_80 = abs (pdr_pro_80 - 0.80);

pdr70_pro_rd1 = GetPdrStdArray('PRKS70_every_link_pdrs_rd1.txt');
pdr70_pro_rd2 = GetPdrStdArray('PRKS70_every_link_pdrs_rd2.txt');
pdr70_pro_rd3 = GetPdrStdArray('PRKS70_every_link_pdrs_rd3.txt');
pdr70_pro_rd4 = GetPdrStdArray('PRKS70_every_link_pdrs_rd4.txt');
pdr70_pro_rd5 = GetPdrStdArray('PRKS70_every_link_pdrs_rd5.txt');
pdr_pro_70 = [pdr70_pro_rd1; pdr70_pro_rd2;pdr70_pro_rd3; pdr70_pro_rd4; pdr70_pro_rd5];
%pdr_pro_70 = abs (pdr_pro_70 - 0.70);


%%PRKS_L
pdr95_nopro_rd1 = GetPdrStdArray('PRKS_L95_every_link_pdrs_rd1.txt');
pdr95_nopro_rd2 = GetPdrStdArray('PRKS_L95_every_link_pdrs_rd2.txt');
pdr95_nopro_rd3 = GetPdrStdArray('PRKS_L95_every_link_pdrs_rd3.txt');
pdr95_nopro_rd4 = GetPdrStdArray('PRKS_L95_every_link_pdrs_rd4.txt');
pdr95_nopro_rd5 = GetPdrStdArray('PRKS_L95_every_link_pdrs_rd5.txt');
pdr_nopro_95 = [pdr95_nopro_rd1; pdr95_nopro_rd2;pdr95_nopro_rd3; pdr95_nopro_rd4; pdr95_nopro_rd5];
%pdr_nopro_95 = abs (pdr_nopro_95  - 0.95);

pdr90_nopro_rd1 = GetPdrStdArray('PRKS_L90_every_link_pdrs_rd1.txt');
pdr90_nopro_rd2 = GetPdrStdArray('PRKS_L90_every_link_pdrs_rd2.txt');
pdr90_nopro_rd3 = GetPdrStdArray('PRKS_L90_every_link_pdrs_rd3.txt');
pdr90_nopro_rd4 = GetPdrStdArray('PRKS_L90_every_link_pdrs_rd4.txt');
pdr90_nopro_rd5 = GetPdrStdArray('PRKS_L90_every_link_pdrs_rd5.txt');
pdr_nopro_90 = [pdr90_nopro_rd1; pdr90_nopro_rd2;pdr90_nopro_rd3; pdr90_nopro_rd4; pdr90_nopro_rd5];
%pdr_nopro_90 = abs (pdr_nopro_90  - 0.90);

pdr80_nopro_rd1 = GetPdrStdArray('PRKS_L80_every_link_pdrs_rd1.txt');
pdr80_nopro_rd2 = GetPdrStdArray('PRKS_L80_every_link_pdrs_rd2.txt');
pdr80_nopro_rd3 = GetPdrStdArray('PRKS_L80_every_link_pdrs_rd3.txt');
pdr80_nopro_rd4 = GetPdrStdArray('PRKS_L80_every_link_pdrs_rd4.txt');
pdr80_nopro_rd5 = GetPdrStdArray('PRKS_L80_every_link_pdrs_rd5.txt');
pdr_nopro_80 = [pdr80_nopro_rd1; pdr80_nopro_rd2;pdr80_nopro_rd3; pdr80_nopro_rd4; pdr80_nopro_rd5];
%pdr_nopro_80 = abs (pdr_nopro_80  - 0.80);

pdr70_nopro_rd1 = GetPdrStdArray('PRKS_L70_every_link_pdrs_rd1.txt');
pdr70_nopro_rd2 = GetPdrStdArray('PRKS_L70_every_link_pdrs_rd2.txt');
pdr70_nopro_rd3 = GetPdrStdArray('PRKS_L70_every_link_pdrs_rd3.txt');
pdr70_nopro_rd4 = GetPdrStdArray('PRKS_L70_every_link_pdrs_rd4.txt');
pdr70_nopro_rd5 = GetPdrStdArray('PRKS_L70_every_link_pdrs_rd5.txt');
pdr_nopro_70 = [pdr70_nopro_rd1; pdr70_nopro_rd2;pdr70_nopro_rd3; pdr70_nopro_rd4; pdr70_nopro_rd5];
%pdr_nopro_70 = abs (pdr_nopro_70  - 0.70);

%%PRKS_R
pdr95_p1_rd1 = GetPdrStdArray('PRKS_R95_every_link_pdrs_rd1.txt');
pdr95_p1_rd2 = GetPdrStdArray('PRKS_R95_every_link_pdrs_rd2.txt');
pdr95_p1_rd3 = GetPdrStdArray('PRKS_R95_every_link_pdrs_rd3.txt');
pdr95_p1_rd4 = GetPdrStdArray('PRKS_R95_every_link_pdrs_rd4.txt');
pdr95_p1_rd5 = GetPdrStdArray('PRKS_R95_every_link_pdrs_rd5.txt');
pdr_p1_95 = [pdr95_p1_rd1; pdr95_p1_rd2;pdr95_p1_rd3; pdr95_p1_rd4; pdr95_p1_rd5];
%pdr_p1_95 = abs (pdr_p1_95 - 0.95);

pdr90_p1_rd1 = GetPdrStdArray('PRKS_R90_every_link_pdrs_rd1.txt');
pdr90_p1_rd2 = GetPdrStdArray('PRKS_R90_every_link_pdrs_rd2.txt');
pdr90_p1_rd3 = GetPdrStdArray('PRKS_R90_every_link_pdrs_rd3.txt');
pdr90_p1_rd4 = GetPdrStdArray('PRKS_R90_every_link_pdrs_rd4.txt');
pdr90_p1_rd5 = GetPdrStdArray('PRKS_R90_every_link_pdrs_rd5.txt');
pdr_p1_90 = [pdr90_p1_rd1; pdr90_p1_rd2;pdr90_p1_rd3; pdr90_p1_rd4; pdr90_p1_rd5];
%pdr_p1_90 = abs (pdr_p1_90 - 0.90);

pdr80_p1_rd1 = GetPdrStdArray('PRKS_R80_every_link_pdrs_rd1.txt');
pdr80_p1_rd2 = GetPdrStdArray('PRKS_R80_every_link_pdrs_rd2.txt');
pdr80_p1_rd3 = GetPdrStdArray('PRKS_R80_every_link_pdrs_rd3.txt');
pdr80_p1_rd4 = GetPdrStdArray('PRKS_R80_every_link_pdrs_rd4.txt');
pdr80_p1_rd5 = GetPdrStdArray('PRKS_R80_every_link_pdrs_rd5.txt');
pdr_p1_80 = [pdr80_p1_rd1; pdr80_p1_rd2;pdr80_p1_rd3; pdr80_p1_rd4; pdr80_p1_rd5];
%pdr_p1_80 = abs (pdr_p1_80 - 0.80);

pdr70_p1_rd1 = GetPdrStdArray('PRKS_R70_every_link_pdrs_rd1.txt');
pdr70_p1_rd2 = GetPdrStdArray('PRKS_R70_every_link_pdrs_rd2.txt');
pdr70_p1_rd3 = GetPdrStdArray('PRKS_R70_every_link_pdrs_rd3.txt');
pdr70_p1_rd4 = GetPdrStdArray('PRKS_R70_every_link_pdrs_rd4.txt');
pdr70_p1_rd5 = GetPdrStdArray('PRKS_R70_every_link_pdrs_rd5.txt');
pdr_p1_70 = [pdr70_p1_rd1; pdr70_p1_rd2;pdr70_p1_rd3; pdr70_p1_rd4; pdr70_p1_rd5];
%pdr_p1_70 = abs (pdr_p1_70 - 0.70);





ALPHA=0.05;



STD = zeros(4,3);
Error_STD = zeros(4,3);
STD(1,1) = std(pdr_pro_70);
STD(1,2) = std(pdr_p1_70);
%STD(1,3) = std(pdr_p2_70);
STD(1,3) = std(pdr_nopro_70);
Error_STD(1,1) =  norminv(1 - ALPHA / 2, 0, 1) * std(pdr_pro_70) / sqrt(size(pdr_pro_70, 1));
Error_STD(1,2) =  norminv(1 - ALPHA / 2, 0, 1) * std(pdr_p1_70) / sqrt(size(pdr_p1_70, 1));
%Error_STD(1,3) =  norminv(1 - ALPHA / 2, 0, 1) * std(pdr_p2_70) / sqrt(size(pdr_p2_70, 1));
Error_STD(1,3) =  norminv(1 - ALPHA / 2, 0, 1) * std(pdr_nopro_70) / sqrt(size(pdr_nopro_70, 1));

STD(2,1) = std(pdr_pro_80);
STD(2,2) = std(pdr_p1_80);
%STD(2,3) = std(pdr_p2_80);
STD(2,3) = std(pdr_nopro_80);
Error_STD(2,1) =  norminv(1 - ALPHA / 2, 0, 1) * std(pdr_pro_80) / sqrt(size(pdr_pro_80, 1));
Error_STD(2,2) =  norminv(1 - ALPHA / 2, 0, 1) * std(pdr_p1_80) / sqrt(size(pdr_p1_80, 1));
%Error_STD(2,3) =  norminv(1 - ALPHA / 2, 0, 1) * std(pdr_p2_80) / sqrt(size(pdr_p2_80, 1));
Error_STD(2,3) =  norminv(1 - ALPHA / 2, 0, 1) * std(pdr_nopro_80) / sqrt(size(pdr_nopro_80, 1));
STD(3,1) = std(pdr_pro_90);
STD(3,2) = std(pdr_p1_90);
%STD(3,3) = std(pdr_p2_90);
STD(3,3) = std(pdr_nopro_90);
Error_STD(3,1) =  norminv(1 - ALPHA / 2, 0, 1) * std(pdr_pro_90) / sqrt(size(pdr_pro_90, 1));
Error_STD(3,2) =  norminv(1 - ALPHA / 2, 0, 1) * std(pdr_p1_90) / sqrt(size(pdr_p1_90, 1));
%Error_STD(3,3) =  norminv(1 - ALPHA / 2, 0, 1) * std(pdr_p2_90) / sqrt(size(pdr_p2_90, 1));
Error_STD(3,3) =  norminv(1 - ALPHA / 2, 0, 1) * std(pdr_nopro_90) / sqrt(size(pdr_nopro_90, 1));
STD(4,1) = std(pdr_pro_95);
STD(4,2) = std(pdr_p1_95);
%STD(4,3) = std(pdr_p2_95);
STD(4,3) = std(pdr_nopro_95);
Error_STD(4,1) =  norminv(1 - ALPHA / 2, 0, 1) * std(pdr_pro_95) / sqrt(size(pdr_pro_95, 1));
Error_STD(4,2) =  norminv(1 - ALPHA / 2, 0, 1) * std(pdr_p1_95) / sqrt(size(pdr_p1_95, 1));
%Error_STD(4,3) =  norminv(1 - ALPHA / 2, 0, 1) * std(pdr_p2_95) / sqrt(size(pdr_p2_95, 1));
Error_STD(4,3) =  norminv(1 - ALPHA / 2, 0, 1) * std(pdr_nopro_95) / sqrt(size(pdr_nopro_95, 1));
STD
figure;
handle = barweb(STD, Error_STD,1, ['70%'; '80%'; '90%'; '95%'], [''], ['PDR requirement'], ['Mean standard deviation'], jet);
%handle = barweb(STD*100, 1, ['70%'; '80%'; '90%'; '95%'], [''], ['PDR requirement'], ['Standard deviation'], jet);
%handle = barweb(STD*100, Error_STD*100,1, ['70%'; '80%'; '90%'; '95%'], [''], ['PDR requirement'], ['Mean deviation from requirement'], [1 1 1; 0.6 0.6 0.6; 0.15 0.15 0.15; 0 0 0]);
%legend ('PRKS','PRKS\_L','RID','PRKS\_R','PRKS\_RI');
handle.legend =legend ('PRKS  ','PRKS-R  ','PRKS-L  ','orientation','horizontal');
set(gca, 'YTickLabel', sprintf('%d%%|', 0:1:3))
set(gca,'fontsize',60);
%ylim(0,2);
box on
maximize ();
%saveas (gcf, 'std_pdr_all_prks_versions.jpg');
%saveas (gcf, 'std_pdr_all_prks_versions.eps');
%saveas (gcf, 'std_pdr_all_prks_versions.fig');
